home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / term-source.lha / Start.c < prev    next >
C/C++ Source or Header  |  1995-09-26  |  3KB  |  147 lines

  1. /*
  2. **    Start.c
  3. **
  4. **    The program entry point
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include <intuition/intuitionbase.h>
  11.  
  12. #include <workbench/workbench.h>
  13.  
  14. #include <exec/execbase.h>
  15.  
  16. #include <dos/dosextens.h>
  17.  
  18. #include <clib/intuition_protos.h>
  19. #include <clib/exec_protos.h>
  20. #include <clib/dos_protos.h>
  21.  
  22. #include <pragmas/intuition_pragmas.h>
  23. #include <pragmas/exec_pragmas.h>
  24. #include <pragmas/dos_pragmas.h>
  25.  
  26. #include <string.h>
  27.  
  28.     /* Standard topaz.font/8. */
  29.  
  30. extern struct TextAttr     DefaultFont;
  31.  
  32.     /* exec.library base pointer. */
  33.  
  34. extern struct ExecBase    *SysBase;
  35.  
  36.     /* The appropriate machine type check. */
  37.  
  38. #if defined(CPU_ANY) || defined(CPU_any)
  39. #define MACHINE_OKAY (1)
  40. #endif
  41.  
  42. #if defined(CPU_68020) || defined(CPU_68030)
  43. #define MACHINE_OKAY (SysBase -> AttnFlags & AFF_68020)
  44. #endif
  45.  
  46. #if defined(CPU_68040)
  47. #define MACHINE_OKAY (SysBase -> AttnFlags & AFF_68040)
  48. #endif
  49.  
  50.     /* Start():
  51.      *
  52.      *    Program entry point, checks for the right CPU type and
  53.      *    runs the main program if possible.
  54.      */
  55.  
  56. LONG __saveds
  57. Start(VOID)
  58. {
  59.         /* Get SysBase. */
  60.  
  61.     SysBase = *(struct ExecBase **)4;
  62.  
  63.         /* Is the minimum required processor type and Kickstart 2.04 (or higher)
  64.          * available?
  65.          */
  66.  
  67.     if(MACHINE_OKAY && (SysBase -> LibNode . lib_Version > 37 || (SysBase -> LibNode . lib_Version == 37 && SysBase -> SoftVer >= 175)))
  68.         return(main());
  69.     else
  70.     {
  71.         register struct Process *ThisProcess = (struct Process *)SysBase -> ThisTask;
  72.  
  73.             /* Is a Shell window available? */
  74.  
  75.         if(ThisProcess -> pr_CLI)
  76.         {
  77.             register struct DosLibrary *DOSBase;
  78.  
  79.                 /* Show the message. */
  80.  
  81.             if(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",0))
  82.             {
  83.                 STRPTR String;
  84.  
  85.                 if(MACHINE_OKAY)
  86.                     String = "Kickstart 2.04 or higher required.\a\n";
  87.                 else
  88.                     String = "MC68020 or higher required.\a\n";
  89.  
  90.                 Write(ThisProcess -> pr_COS,String,strlen(String));
  91.  
  92.                 CloseLibrary(DOSBase);
  93.             }
  94.  
  95.             return(RETURN_FAIL);
  96.         }
  97.         else
  98.         {
  99.             register struct IntuitionBase    *IntuitionBase;
  100.             register struct WBStartup    *WBenchMsg;
  101.  
  102.                 /* Wait for startup message. */
  103.  
  104.             WaitPort(&ThisProcess -> pr_MsgPort);
  105.  
  106.                 /* Get the message. */
  107.  
  108.             WBenchMsg = (struct WBStartup *)GetMsg(&ThisProcess -> pr_MsgPort);
  109.  
  110.                 /* Show the message. */
  111.  
  112.             if(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0))
  113.             {
  114.                 STATIC struct IntuiText SorryText = {0,1,JAM1,6,3,&DefaultFont,(UBYTE *)"Sorry",NULL};
  115.  
  116.                 struct IntuiText    *Body;
  117.                 UWORD             Width;
  118.  
  119.                 if(MACHINE_OKAY)
  120.                 {
  121.                     STATIC struct IntuiText BodyText = {0,1,JAM1,5,3,&DefaultFont,(STRPTR)"Kickstart 2.04 or higher required.",NULL};
  122.  
  123.                     Body    = &BodyText;
  124.                     Width    = 309;
  125.                 }
  126.                 else
  127.                 {
  128.                     STATIC struct IntuiText BodyText = {0,1,JAM1,5,3,&DefaultFont,(UBYTE *)"MC68020 or higher required.",NULL};
  129.  
  130.                     Body    = &BodyText;
  131.                     Width    = 253;
  132.                 }
  133.  
  134.                 AutoRequest(NULL,Body,NULL,&SorryText,NULL,NULL,Width,46);
  135.  
  136.                 CloseLibrary(IntuitionBase);
  137.             }
  138.  
  139.                 /* Return the startup message and exit. */
  140.  
  141.             Forbid();
  142.  
  143.             ReplyMsg((struct Message *)WBenchMsg);
  144.         }
  145.     }
  146. }
  147.